<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    class Animal {
        constructor(name, age) {
            this.name = name
            this.age = age
        }

        sayName() {
            return this.name
        }

        sayAge() {
            return this.age
        }
    }

    class Dog extends Animal {
        constructor(name, age, color) {
            super(name, age); // 调用父类的方法
            this.color = color
        }

        getInfo() {
            return `${this.name}现在${this.age}岁了，它的肤色是${this.color}的`
        }

        // 重写父类方法
        sayName() {
            return '狗狗' + this.name
        }
    }

    let d = new Dog('小黄', 3, '黄色')
    console.log(d)
    console.log(d.getInfo())
</script>
</body>
</html>
